package jianzhiOfferII;

import java.util.ArrayList;
import java.util.List;

//剑指 Offer II 052. 展平二叉搜索树
public class Num052_increasingBST {
    private List<Integer> list = new ArrayList<>();
    public TreeNode increasingBST(TreeNode root) {
        inorder(root);
        TreeNode dummmyNode = new TreeNode(-1);
        TreeNode currNode = dummmyNode;
        for (int i : list){
            currNode.right = new TreeNode(i);
            currNode = currNode.right;
        }
        return dummmyNode.right;


    }
    public void inorder(TreeNode root){
        if (root == null)return;
        inorder(root.left);
        list.add(root.val);
        inorder(root.right);
    }
}
